#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time: 2025-07-26 23:46
@Author: Fallyn Snow 
@File: awaiting_future.py
"""

import asyncio
from asyncio import Future


async def set_future_value(future: Future) -> None:
    await asyncio.sleep(1)
    future.set_result(233)


def make_request() -> Future:
    future = Future()
    asyncio.create_task(set_future_value(future))
    return future


async def main():
    future = make_request()
    print(f"这个future的是否完成: {future.done()}")
    # 此时await的功能是暂停main, 直到这个future的值(result)被设置(set)
    value = await future
    print(f"这个future是否完成: {future.done()}")
    print(value)


async def foo():
    pass

if __name__ == '__main__':
    asyncio.run(main())

